<!DOCTYPE html>
<html>
<head>
    <title>维护规程管理</title>
    #parse("sys/header.html")
    <style>
        .sugon_upload_btn {
            display: -webkit-inline-box;
            display: inline-block;
        }
        .from_tab_wide {
            width: 90% !important;
            padding-top: 1% !important;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <table id="jqGrid"></table>
    </div>
</div>
<script>
    $(function () {
        var queryUrl = '../devammaintenancerules/list';
        var devId = getQueryString('devId');
        if(devId){
            queryUrl += '?devId=' + devId;
        }
        $("#jqGrid").Grid({
            url: queryUrl,
            multiselect: false,
            rownumWidth: 35,
            rowNum: 10,
            rowList: [10, 20, 30],
            colModel: [
                {label: '规程名称', name: 'ruleName', index: 'RULE_NAME', width: 80,sortable: false},
                {label: '设备编码', name: 'deviceCode', index: 'DEV_CODE', width: 60,sortable: false},
                {label: '设备名称', name: 'deviceName', index: 'DEV_NAME', width: 70,sortable: false},
                {label: '车间', name: 'shop', index: 'WORKSHOP_NAME', width: 70,sortable: false},
                {label: '产线', name: 'line', index: 'PRO_LINE_NAME', width: 80,sortable: false},
                {label: '工序号', name: 'proce', index: 'AREA_LINE_ID', width: 40,sortable: false},
                {label: '版本', name: 'planVersion', index: 'PLAN_VERSION', width: 50},
                {
                    label: '审核', width: 40, sortable: false,sortable: false,
                    formatter: function (value, col, row) {
                        return "<button class='btn btn-outline btn-info' id='recordsText' onclick='vm.shviewOption(\"" + escape(JSON.stringify(row)) + "\")'>&nbsp;详情</button>";
                    }
                },
                {
                    label: '维护项', width: 40, sortable: false,sortable: false,
                    formatter: function (value, col, row) {
                        return "<button class='btn btn-outline btn-info' id='recordsText' onclick='vm.viewOption(\"" + row.id + "\")'>&nbsp;详情</button>";
                    }
                },
                {name: 'id', key: true, hidden: true},
                {name: 'progress', hidden: true}
            ]
        });
    });

    var vm = new Vue({
        el: '#rrapp',
        data: {},
        methods: {
            //审核详情
            shviewOption: function (res) {
                var data = JSON.parse(unescape(res))
                Ajax.request({
                    url: '../sysProcess/approve',
                    params: {bussinessId: data.id},
                    type: 'POST',
                    successCallback: function (res) {
                        var approveProcessList = res.approveProcessList;
                        if (approveProcessList.length == 0) {
                            iview.Message.error("暂无审批记录");
                            return;
                        }
                        var dom = "<div class='details'><table>";
                        for (var i = 0; i < approveProcessList.length; i++) {
                            var approveProcess = approveProcessList[i];
                            dom += '<tr><td>' + approveProcess.approveDate + '</td>';
                            dom += '<td align="left">' + approveProcess.roleName + '-' + approveProcess.name + '： ' + sysEnums.CHECK_FLAG[approveProcess.status];
                            if (approveProcess.remark) {
                                dom += '<br />备注：' + approveProcess.remark;
                            }
                            dom += '</td></tr>'
                        }
                        dom += '</table></div>'
                        layer.open({
                            type: 1,
                            title: "审核详情",
                            closeBtn: 0,
                            area: ['500px'],
                            offset: '10vh',
                            shadeClose: true,
                            skin: 'yourclass',
                            content: dom
                        });
                    }
                });
            },
            //查看详情
            viewOption: function (plan_id) {
                openWindow({
                    type: 2,
                    title: '<i class="fa fa-file-text-o"></i> 查看详情',
                    content: '../device/devAmRulesView.html?planId=' + plan_id
                })
            }
        }
    });
</script>
</body>
</html>
